package cn.hanna.springcloudalibaba.controller;

import cn.hanna.springcloud.entities.CommonResult;
import cn.hanna.springcloudalibaba.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

/**
 * @author smileha
 * @create 2021-10-23 1:09
 * @description
 */
@RestController
public class AccountController {

    @Autowired
    private AccountService accountService;

    @PostMapping("/account/decrease/{id}/{money}")
    public CommonResult decrease(@PathVariable("id") Long userId,
                          @PathVariable("money") BigDecimal money) throws InterruptedException {
        TimeUnit.SECONDS.sleep(5);
        accountService.decrease(userId,money);
        return new CommonResult(200,"修改账户余额完成",null);
    }
}
